<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
    <title>angularJs入门demo，内置服务$http</title>
    <script src="angular.min.js"></script>
    <script>
        //建立模块
        var app = angular.module("myApp",[]);
        //这个控制器本身就是一个方法，类似于一个类
        //用到http服务了，就必须注入
        app.controller("myController", function ($scope, $http) {
            $scope.findList = function () {
                //实际中就是XXX.do
                $http({
                    method:'GET',
                    url:'/data.json'
                }).then(function (response) {
                    $scope.list = response.data;
                })
                //下面不写的话，就放在ng-init里面，放这里，就是用到控制层就显示了，不太好
//                $scope.findList();
            }
        })
    </script>
</head>
<body ng-app="myApp" ng-controller="myController" ng-init="findList()">
<table>
    <!--循环tr，就在这加-->
    <!--表头和循环-->
    <tr>
        <td>姓名</td>
        <td>数学</td>
        <td>语文</td>
    </tr>
    <tr ng-repeat="entity in list">
        <td>{{entity.name}}</td>
        <td>{{entity.shuxue}}</td>
        <td>{{entity.yuwen}}
        <td>
    </tr>
</table>
</body>
</html>